﻿#include "LineChartCenterSettingDialog.h"
#include "ui_LineChartCenterSettingDialog.h"

#include <QPushButton>
#include <QLineEdit>
#include <QComboBox>
#include <QCheckBox>
#include <QTableWidgetItem>
#include <QHeaderView>
#include <QtGlobal>

#include "IdaWidgetHelper.h"
#include "LineChartCoordinateSettingData.h"
#include "StyleComboBox.h"
#include "UnitHelper.h"
#include "LineChartWindow.h"

#include "BaseWidget/DoubleSpinBox.h"
#include "BaseWidget/EColorComboBox.h"
#include "BaseModule/IBaseSignal.h"
#include "BaseModule/GlobalHelper.h"
#include "BaseWidget/IdaDialogMsg.h"

namespace
{
    QStringList g_linwWith = {"0.5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
    QStringList g_fontSize = {"8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "36", "42", "72"};
} // namespace

namespace pst
{
    LineChartCenterSettingDialog::LineChartCenterSettingDialog(QWidget* parent)
        : IdaDialogFrame(parent), ui(new Ui::LineChartCenterSettingDialog()), m_tableWidget_xAxisDisplay(nullptr), m_tableWidget_xAxisRange(nullptr), m_tableWidget_yAxisDisplay(nullptr), m_tableWidget_yAxisRange(nullptr), m_tableWidget_grid(nullptr), m_tableWidget_title(nullptr), m_tableWidget_legend(nullptr), m_tableWidget_dataProperty(nullptr), m_dataGraph2DSettings(nullptr)
    {
        ui->setupUi(this);

        initWidget();
    }

    LineChartCenterSettingDialog::~LineChartCenterSettingDialog()
    {
        delete ui;
        //if (m_dataGraph2DSettings)
        //{
        //    delete m_dataGraph2DSettings;
        //    m_dataGraph2DSettings = nullptr;
        //}
    }

    void LineChartCenterSettingDialog::initWidget()
    {
        setWindowSize(740, 400);
        setWindowTitle(QStringLiteral("显示设置"));

        // auto _button_apply = new QPushButton(QStringLiteral("应用"));
        // ui->buttonBox->addButton(_button_apply, QDialogButtonBox::YesRole);
        connect(ui->pushButton_reject, &QPushButton::clicked, this, &LineChartCenterSettingDialog::reject);
        connect(ui->pushButton_accept, &QPushButton::clicked, this, &LineChartCenterSettingDialog::accept);
        connect(ui->pushButton_apply, &QPushButton::clicked, this, &LineChartCenterSettingDialog::slot_apply);

        IdaWidgetHelperInstance->setMainButtonStyle(ui->pushButton_accept); // 将确定设置为主按钮

        m_tableWidget_xAxisDisplay = initData_xAxisDisplay(0);
        m_tableWidget_xAxisRange = initData_xAxisRange();
        m_tableWidget_yAxisDisplay = initData_yAxisDisplay();
        m_tableWidget_yAxisRange = initData_yAxisRange();
        m_tableWidget_grid = initData_grid();
        m_tableWidget_title = initData_title();
        m_tableWidget_legend = initData_legend();
        m_tableWidget_dataProperty = initData_dataProperty();

        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_xAxisDisplay);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_xAxisRange);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_yAxisDisplay);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_yAxisRange);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_grid);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_title);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_legend);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_dataProperty);

        ui->gridLayout_xAxisDisplay->addWidget(m_tableWidget_xAxisDisplay);
        ui->gridLayout_xAxisRange->addWidget(m_tableWidget_xAxisRange);
        ui->gridLayout_yAxisDisplay->addWidget(m_tableWidget_yAxisDisplay);
        ui->gridLayout_yAxisRange->addWidget(m_tableWidget_yAxisRange);
        ui->gridLayout_grid->addWidget(m_tableWidget_grid);
        ui->gridLayout_title->addWidget(m_tableWidget_title);
        ui->gridLayout_legend->addWidget(m_tableWidget_legend);
        ui->gridLayout_dataProperty->addWidget(m_tableWidget_dataProperty);

        //m_dataGraph2DSettings = new LineChartCoordinateSettingData();

        // 将数据实例指针 传递给 临时数据类进行数据复制
        // m_dataGraph2DSettings->copyData(数据实例指针);

        return;
        updateUIData_xAxisDisplay();
        updateUIData_xAxisRange();
        updateUIData_yAxisDisplay();
        updateUIData_yAxisRange();
        updateUIData_grid();
        updateUIData_title();
        updateUIData_legend();
        updateUIData_dataProperty();
    }

    void LineChartCenterSettingDialog::InitData( LineChartCenterSettingData* dataGraph2DSettings)
    {
        if (dataGraph2DSettings != nullptr)
        {
            m_dataGraph2DSettings = dataGraph2DSettings;
            //m_dataGraph2DSettings->copyData(dataGraph2DSettings);
            updateUIData_xAxisDisplay();
            updateUIData_xAxisRange();
            updateUIData_yAxisDisplay();
            updateUIData_yAxisRange();
            updateUIData_grid();
            updateUIData_title();
            updateUIData_legend();
            updateUIData_dataProperty();
        }
    }

    void LineChartCenterSettingDialog::ChangeCurrentWidget(int index)
    {
        if (index != 7)
        {
            ui->tabWidget->setTabEnabled(7, false);
        }
        else
        {
            ui->tabWidget->setTabEnabled(7, true);
        }
        ui->tabWidget->setCurrentIndex(index);
    }

    void LineChartCenterSettingDialog::setWindowUniversalID(int windowUniversalID)
    {
        m_windowUniversalID = windowUniversalID;
    }

    void LineChartCenterSettingDialog::setIndexOfGraph(int index)
    {
        m_indexOfGraph = index;
    }

    int LineChartCenterSettingDialog::getIndexOfGrapg() const
    {
        return m_indexOfGraph;
    }

    void LineChartCenterSettingDialog::reject()
    {

        IdaDialogFrame::reject();
    }

    void LineChartCenterSettingDialog::accept()
    {
        if (slot_apply())
        {
            IdaDialogFrame::accept();
        }
    }

    bool LineChartCenterSettingDialog::slot_apply()
    {
        // emit pyScriptIsRunning();
        // m_pyCode.clear();
        // m_pyCode.append(QString("linechartmainsetting = PostProcessing.LineChartMainSetting()"));
        // m_pyCode.append(QString("linechartmainsetting.setWindowId(%1)").arg(m_windowUniversalID));
        // m_pyCode.append(QString("linechartmainsetting.setIndexOfGraph(%1)").arg(m_indexOfGraph));
        saveUIData_xAxisDisplay();
        if (!saveUIData_xAxisRange())
        {
            return false;
        }
        saveUIData_yAxisDisplay();
        if (!saveUIData_yAxisRange())
        {
            return false;
        }
        auto _dataProperty = m_dataGraph2DSettings->m_style2D_DataProperty;
        if (_dataProperty != nullptr)
        {
            QString newName = ((QLineEdit*)m_tableWidget_dataProperty->cellWidget(0, 1))->text();
            if (newName.isEmpty())
            {
                IdaDialogMsg::showDialog(this, QString("命名不能为空，请重新编辑。"), EDialogMsg::Error, tr("重命名错误"));
                return false;
            }
            bool exist = false;
            emit signal_checkCurveNameExist(newName, exist);
            if (exist)
            {
                IdaDialogMsg::showDialog(this, QString("当前名称已存在，请重新编辑。"), EDialogMsg::Error, tr("重命名错误"));
                return false;
            }
        }

        saveUIData_grid();
        saveUIData_title();
        saveUIData_legend();
        saveUIData_dataProperty();
        // m_pyCode.append(QString("linechartmainsetting.saveLineChartMainSettingData()"));
        // emit IBaseSignalInstance->signal_execPYCode(m_pyCode, true, false);

        //------以下代码必须放在emit IBaseSignalInstance->signal_execPYCode(m_pyCode, true, false);之后执行--------
        auto _xAxisDisplay = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getXAxisDisplay();
        QString axiDisTitleFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_xAxisDisplay->m_titleFontColor.red(), _xAxisDisplay->m_titleFontColor.green(), _xAxisDisplay->m_titleFontColor.blue()});
        QString axiDisAxisColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_xAxisDisplay->m_axisColor.red(), _xAxisDisplay->m_axisColor.green(), _xAxisDisplay->m_axisColor.blue()});
        QString axiDisAxisDigitColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_xAxisDisplay->m_axisDigitColor.red(), _xAxisDisplay->m_axisDigitColor.green(), _xAxisDisplay->m_axisDigitColor.blue()});

        auto _xAxisRange = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getXAxisRange();

        auto _yAxisDisplay = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getYAxisDisplay();
        QString yAxiDisTitleFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_yAxisDisplay->m_titleFontColor.red(), _yAxisDisplay->m_titleFontColor.green(), _yAxisDisplay->m_titleFontColor.blue()});
        QString yAxiDisAxisColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_yAxisDisplay->m_axisColor.red(), _yAxisDisplay->m_axisColor.green(), _yAxisDisplay->m_axisColor.blue()});
        QString yAxiDisAxisDigitColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_yAxisDisplay->m_axisDigitColor.red(), _yAxisDisplay->m_axisDigitColor.green(), _yAxisDisplay->m_axisDigitColor.blue()});

        auto _yAxisRange = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getYAxisRange();

        auto _grid = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getGrid();
        QString gridMainGridLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_grid->m_mainGridLineColor.red(), _grid->m_mainGridLineColor.green(), _grid->m_mainGridLineColor.blue()});
        QString gridSecondaryGridLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_grid->m_secondaryGridLineColor.red(), _grid->m_secondaryGridLineColor.green(), _grid->m_secondaryGridLineColor.blue()});

        auto _title = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getTitle();
        QString titleFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_title->m_titleFontColor.red(), _title->m_titleFontColor.green(), _title->m_titleFontColor.blue()});

        auto _legend = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getLegend();
        QString legendFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_legend->m_legendFontColor.red(), _legend->m_legendFontColor.green(), _legend->m_legendFontColor.blue()});
        QString legendLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_legend->m_legendLineColor.red(), _legend->m_legendLineColor.green(), _legend->m_legendLineColor.blue()});

        //auto _dataProperty = m_dataGraph2DSettings->m_style2D_DataProperty;
        if (_dataProperty)
        {
            QString dataLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_dataProperty->m_dataLineColor.red(), _dataProperty->m_dataLineColor.green(), _dataProperty->m_dataLineColor.blue()});
            QString symbolColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{_dataProperty->m_symbolColor.red(), _dataProperty->m_symbolColor.green(), _dataProperty->m_symbolColor.blue()});
        }
   
        //emit IBaseSignalInstance->signal_saveLineChartMainSettingData(
        //    m_windowId,
        //    m_indexOfGraph,
        //    _xAxisDisplay->m_isAutoName,
        //    _xAxisDisplay->m_titleText,
        //    axiDisTitleFontColorStr,
        //    _xAxisDisplay->m_titleFontSize,
        //    axiDisAxisColorStr,
        //    _xAxisDisplay->m_axisThickness,
        //    _xAxisDisplay->m_valuePrecision,
        //    axiDisAxisDigitColorStr,
        //    _xAxisDisplay->m_axisDigitSize,
        //    _xAxisRange->m_isAutoRange,
        //    _xAxisRange->m_maxValue,
        //    _xAxisRange->m_minValue,
        //    _xAxisRange->m_isAutoStepSize,
        //    _xAxisRange->m_customStepSize,
        //    _yAxisDisplay->m_isAutoName,
        //    _yAxisDisplay->m_titleText,
        //    yAxiDisTitleFontColorStr,
        //    _yAxisDisplay->m_titleFontSize,
        //    yAxiDisAxisColorStr,
        //    _yAxisDisplay->m_axisThickness,
        //    _yAxisDisplay->m_valuePrecision,
        //    yAxiDisAxisDigitColorStr,
        //    _yAxisDisplay->m_axisDigitSize,
        //    _yAxisRange->m_isAutoRange,
        //    _yAxisRange->m_maxValue,
        //    _yAxisRange->m_minValue,
        //    _yAxisRange->m_isAutoStepSize,
        //    _yAxisRange->m_customStepSize,
        //    _grid->m_isMainGridLineDisplay,
        //    gridMainGridLineColorStr,
        //    _grid->m_mainGridLineStyle,
        //    _grid->m_mainGridLineThickness,
        //    _grid->m_isSecondaryGridLineDisplay,
        //    gridSecondaryGridLineColorStr,
        //    _grid->m_secondaryGridLineStyle,
        //    _grid->m_secondaryGridLineThickness,
        //    _title->m_titleName,
        //    titleFontColorStr,
        //    _title->m_titleFontSize,
        //    legendFontColorStr,
        //    _legend->m_legendFontSize,
        //    legendLineColorStr,
        //    _legend->m_legendLineThickness,
        //    _dataProperty->m_resultDataName,
        //    dataLineColorStr,
        //    _dataProperty->m_dataLineStyle,
        //    _dataProperty->m_dataLineThickness,
        //    _dataProperty->m_isDisplaySymbol,
        //    _dataProperty->m_symbolStyle,
        //    _dataProperty->m_symbolSize,
        //    symbolColorStr);
        
        //------以上代码必须放在emit IBaseSignalInstance->signal_execPYCode(m_pyCode, true, false);之后执行--------

        // 将临时数据类 传递给 数据实例指针进行数据复制
        // 数据实例指针->copyData(m_dataGraph2DSettings);
        emit SignalSendData(m_windowUniversalID, m_curveInfoID);
        return true;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_xAxisDisplay(int axisType)
    {
        auto _tableWidget = new QTableWidget;
        _tableWidget->setColumnCount(2);
        axisType == 0 ? _tableWidget->setRowCount(10) : _tableWidget->setRowCount(12);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动命名")));
        auto _checkBox_isAutoName = new QCheckBox(); // 自动命名
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoName);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题名")));
        auto _lineEdit_title = new QLineEdit; // 标题名
        _tableWidget->setCellWidget(_rowCount, 1, _lineEdit_title);

        /*
         * checkbox 控制禁用状态
         */
        connect(_checkBox_isAutoName, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _lineEdit_title->setEnabled(!checked);
                });

        if (axisType == 1)
        {
            _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("参数类型")));
            auto _comboBox_paraType = new QComboBox; //参数类型
            _tableWidget->setCellWidget(_rowCount, 1, _comboBox_paraType);
            m_comboBox_yAxisUnitType = _comboBox_paraType;
            connect(m_comboBox_yAxisUnitType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineChartCenterSettingDialog::slot_yAxisUnittypeChanged);


            _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("数值类型")));
            auto _comboBox_componentType = new QComboBox; //参数类型
            _tableWidget->setCellWidget(_rowCount, 1, _comboBox_componentType);
            m_comboBox_yAxisComponentType = _comboBox_componentType;
            connect(m_comboBox_yAxisComponentType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineChartCenterSettingDialog::slot_yAxisUnitComponentChanged);
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("变量单位")));
        auto _comboBox_axisUnit = new QComboBox; //x轴变量单位
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisUnit);
        if (axisType == 1)
        {
            m_comboBox_yAxisUnit = _comboBox_axisUnit;
            connect(_comboBox_axisUnit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineChartCenterSettingDialog::slot_yAxisUnitChanged);
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体颜色")));
        auto _comboBox_titleFontColor = new BaseWidget::EColorComboBox; // 标题字体颜色
        _comboBox_titleFontColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体大小")));
        auto _comboBox_titleFontSize = new QComboBox; // 标题字体大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontSize);
        for (int i = 0; i < g_fontSize.size(); ++i)
        {
            _comboBox_titleFontSize->addItem(g_fontSize.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴线颜色")));
        auto _comboBox_axisColor = new BaseWidget::EColorComboBox; // 轴线颜色
        _comboBox_axisColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴线粗细")));
        auto _comboBox_axisThickness = new QComboBox; // 轴线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisThickness);
        for (int i = 0; i < g_linwWith.size(); ++i)
        {
            _comboBox_axisThickness->addItem(g_linwWith.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("数值精度")));
        auto _SpinBox_valuePrecision = new QSpinBox; // 数值精度
        _SpinBox_valuePrecision->setRange(0, 15);
        _tableWidget->setCellWidget(_rowCount, 1, _SpinBox_valuePrecision);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴数字颜色")));
        auto _comboBox_axisDigitColor = new BaseWidget::EColorComboBox; // 轴数字颜色
        _comboBox_axisDigitColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisDigitColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴数字大小")));
        auto _comboBox_axisDigitSize = new QComboBox; // 轴数字大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisDigitSize);
        for (int i = 0; i < g_fontSize.size(); ++i)
        {
            _comboBox_axisDigitSize->addItem(g_fontSize.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_xAxisRange()
    {
        auto _tableWidget = new QTableWidget;
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(5);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动范围")));
        auto _checkBox_isAutoRange = new QCheckBox(); // 自动范围
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoRange);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("最大值")));
        auto _doubleSpinBox_maxValue = new BaseWidget::DoubleSpinBox(); // 最大值
        _doubleSpinBox_maxValue->setRange(-1e15, 1e15);
        _doubleSpinBox_maxValue->setDecimals(15);
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_maxValue);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("最小值")));
        auto _doubleSpinBox_minValue = new BaseWidget::DoubleSpinBox(); // 最小值
        _doubleSpinBox_minValue->setRange(-1e15, 1e15);
        _doubleSpinBox_minValue->setDecimals(15);
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_minValue);
        /*
         * checkbox 控制禁用状态
         */
        connect(_checkBox_isAutoRange, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _doubleSpinBox_maxValue->setEnabled(!checked);
                    _doubleSpinBox_minValue->setEnabled(!checked);
                });

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动步长")));
        auto _checkBox_isAutoStepSize = new QCheckBox(); // 自动步长
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoStepSize);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自定义步长")));
        auto _doubleSpinBox_customStepSize = new BaseWidget::DoubleSpinBox(); // 自定义步长
        _doubleSpinBox_customStepSize->setDecimals(15);
        _doubleSpinBox_customStepSize->setMinimum(0.000000000000001);
        _doubleSpinBox_customStepSize->setMaximum(1000000000000000);
        _doubleSpinBox_customStepSize->setValue(0.01);
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_customStepSize);
        /*
         * checkbox 控制禁用状态
         */
        connect(_checkBox_isAutoStepSize, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _doubleSpinBox_customStepSize->setEnabled(!checked);
                });



        //_tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动最小刻度")));
        // auto _checkBox_isAutoScale = new QCheckBox(); //自动最小刻度
        //_tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoScale);

        //_tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自定义最小刻度数")));
        // auto _doubleSpinBox_mainScaleValue = new BaseWidget::DoubleSpinBox(); //自定义最小刻度数
        //_tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_mainScaleValue);

        //_tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次刻度值")));
        // auto _doubleSpinBox_secondaryScaleValue = new BaseWidget::DoubleSpinBox(); //次刻度值
        //_tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_secondaryScaleValue);

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_yAxisDisplay()
    {

        auto _tableWidget = initData_xAxisDisplay(1);

        return _tableWidget;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_yAxisRange()
    {

        auto _tableWidget = initData_xAxisRange();

        return _tableWidget;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_grid()
    {
        auto _tableWidget = new QTableWidget();
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(8);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线显示")));
        auto _checkBox_isMainGridLineDisplay = new QCheckBox(); // 主网格线显示
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isMainGridLineDisplay);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线颜色")));
        auto _comboBox_mainGridLineColor = new BaseWidget::EColorComboBox; // 主网格线颜色
        _comboBox_mainGridLineColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_mainGridLineColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线样式")));
        auto _comboBox_mainGridLineStyle = new LineStyleComboBox; // 主网格线样式
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_mainGridLineStyle);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线粗细")));
        auto _comboBox_mainGridLineThickness = new QComboBox(); // 主网格线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_mainGridLineThickness);
        for (int i = 0; i < g_linwWith.size(); ++i)
        {
            _comboBox_mainGridLineThickness->addItem(g_linwWith.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线显示")));
        auto _doubleSpinBox_isSecondaryGridLineDisplay = new QCheckBox(); // 次网格线显示
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_isSecondaryGridLineDisplay);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线颜色")));
        auto _comboBox_secondaryGridLineColor = new BaseWidget::EColorComboBox; // 次网格线颜色
        _comboBox_secondaryGridLineColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_secondaryGridLineColor);

        /*
         * 主网格控制次网格状态
         */
        connect(_checkBox_isMainGridLineDisplay, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _doubleSpinBox_isSecondaryGridLineDisplay->setEnabled(checked);
                    if (!checked)
                    {
                        _doubleSpinBox_isSecondaryGridLineDisplay->setChecked(checked);
                    }
                });


        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线样式")));
        auto _comboBox_secondaryGridLineStyle = new LineStyleComboBox; // 次网格线样式
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_secondaryGridLineStyle);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线粗细")));
        auto _comboBox_secondaryGridLineThickness = new QComboBox(); // 次网格线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_secondaryGridLineThickness);
        for (int i = 0; i < g_linwWith.size(); ++i)
        {
            _comboBox_secondaryGridLineThickness->addItem(g_linwWith.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_title()
    {
        auto _tableWidget = new QTableWidget();
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(3);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题名")));
        auto _lineEdit_title = new QLineEdit; // 标题名
        _tableWidget->setCellWidget(_rowCount, 1, _lineEdit_title);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体颜色")));
        auto _comboBox_titleFontColor = new BaseWidget::EColorComboBox; // 标题字体颜色
        _comboBox_titleFontColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体大小")));
        auto _comboBox_titleFontSize = new QComboBox; // 标题字体大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontSize);
        for (int i = 0; i < g_fontSize.size(); ++i)
        {
            _comboBox_titleFontSize->addItem(g_fontSize.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_legend()
    {
        auto _tableWidget = new QTableWidget();
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(4);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("图例字体颜色")));
        auto _comboBox_legendFontColor = new BaseWidget::EColorComboBox; // 图例字体颜色
        _comboBox_legendFontColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_legendFontColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("图例字体大小")));
        auto _comboBox_legendFontSize = new QComboBox; // 图例字体大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_legendFontSize);
        for (int i = 0; i < g_fontSize.size(); ++i)
        {
            _comboBox_legendFontSize->addItem(g_fontSize.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("图例框线颜色")));
        auto _comboBox_legendLineColor = new BaseWidget::EColorComboBox; // 图例框线颜色
        _comboBox_legendLineColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_legendLineColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("图例框线粗细")));
        auto _comboBox_legendLineThickness = new QComboBox; // 图例框线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_legendLineThickness);
        for (int i = 0; i < g_linwWith.size(); ++i)
        {
            _comboBox_legendLineThickness->addItem(g_linwWith.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* LineChartCenterSettingDialog::initData_dataProperty()
    {
        auto _tableWidget = new QTableWidget();
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(8);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("结果数据名称")));
        auto _lineEdit_resultDataName = new QLineEdit; // 结果数据名称
        _tableWidget->setCellWidget(_rowCount, 1, _lineEdit_resultDataName);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("数据线颜色")));
        auto _comboBox_dataLineColor = new BaseWidget::EColorComboBox; // 数据线颜色
        _comboBox_dataLineColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_dataLineColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("数据线样式")));
        auto _comboBox_dataLineStyle = new LineStyleComboBox; // 数据线样式
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_dataLineStyle);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("数据线粗细")));
        auto _comboBox_dataLineThickness = new QComboBox; // 数据线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_dataLineThickness);
        for (int i = 0; i < g_linwWith.size(); ++i)
        {
            _comboBox_dataLineThickness->addItem(g_linwWith.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("是否显示符号")));
        auto _checkBox_isDisplaySymbol = new QCheckBox(); // 是否显示符号
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isDisplaySymbol);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("符号样式")));
        auto _comboBox_symbolStyle = new ScatterStyleComboBox; // 符号样式
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_symbolStyle);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("符号大小")));
        auto _comboBox_symbolSize = new QComboBox; // 符号大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_symbolSize);
        for (int i = 0; i < g_linwWith.size() - 4; ++i)
        {
            _comboBox_symbolSize->addItem(g_linwWith.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("符号颜色")));
        auto _comboBox_symbolColor = new BaseWidget::EColorComboBox; // 符号颜色
        _comboBox_symbolColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_symbolColor);

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    void LineChartCenterSettingDialog::saveUIData_xAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_xAxisDisplay;
        auto _xAxisDisplay = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getXAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_axisUnit = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                           // 单位
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小

        QColor axiDisTitleFontColor = _comboBox_titleFontColor->currentColor();
        QColor axiDisAxisColor = _comboBox_axisColor->currentColor();
        QColor axiDisAxisDigitColor = _comboBox_axisDigitColor->currentColor();

        bool axiDisIsAutoName = _checkBox_isAutoName->isChecked();
        QString axiDisTitleText = _lineEdit_title->text();
        QString axisUnit = _comboBox_axisUnit->currentText();
        QString axiDisTitleFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{axiDisTitleFontColor.red(), axiDisTitleFontColor.green(), axiDisTitleFontColor.blue()});
        int axiDisTitleFontSize = _comboBox_titleFontSize->currentText().toInt();
        QString axiDisAxisColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{axiDisAxisColor.red(), axiDisAxisColor.green(), axiDisAxisColor.blue()});
        int axiDisAxisThickness = _comboBox_axisThickness->currentText().toInt();
        int axiDisValuePrecision = _SpinBox_valuePrecision->value();
        QString axiDisAxisDigitColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{axiDisAxisDigitColor.red(), axiDisAxisDigitColor.green(), axiDisAxisDigitColor.blue()});
        int axiDisAxisDigitSize = _comboBox_axisDigitSize->currentText().toInt();

        _xAxisDisplay->m_isAutoName = axiDisIsAutoName;
        _xAxisDisplay->m_titleText = axiDisTitleText;
        _xAxisDisplay->m_xAxisUnit = axisUnit;
        _xAxisDisplay->m_titleFontColor = axiDisTitleFontColor;
        _xAxisDisplay->m_titleFontSize = axiDisTitleFontSize;
        _xAxisDisplay->m_axisColor = axiDisAxisColor;
        _xAxisDisplay->m_axisThickness = axiDisAxisThickness;
        _xAxisDisplay->m_valuePrecision = axiDisValuePrecision;
        _xAxisDisplay->m_axisDigitColor = axiDisAxisDigitColor;
        _xAxisDisplay->m_axisDigitSize = axiDisAxisDigitSize;

        ////TODO 脚本缺单位保存
        //m_pyCode.append(QString("linechartmainsetting.saveUIData_xAxisDisplay(%1,'%2','%3',%4,'%5',%6, %7,'%8',%9)")
        //                    .arg(axiDisIsAutoName)
        //                    .arg(axiDisTitleText)
        //                    .arg(axiDisTitleFontColorStr)
        //                    .arg(axiDisTitleFontSize)
        //                    .arg(axiDisAxisColorStr)
        //                    .arg(axiDisAxisThickness)
        //                    .arg(axiDisValuePrecision)
        //                    .arg(axiDisAxisDigitColorStr)
        //                    .arg(axiDisAxisDigitSize));
    }

    bool LineChartCenterSettingDialog::saveUIData_xAxisRange()
    {
        auto _tableWidget = m_tableWidget_xAxisRange;
        auto _xAxisRange = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getXAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长
        // auto _checkBox_isAutoScale = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);        //自动最小刻度
        // auto _doubleSpinBox_mainScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);    //自定义最小刻度数
        // auto _doubleSpinBox_secondaryScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);  //次刻度值

        bool axiRangIsAutoRange = _checkBox_isAutoRange->isChecked();
        bool axiRangIsAutoStepSize = _checkBox_isAutoStepSize->isChecked();
        double axiRangCustomStepSize = _doubleSpinBox_customStepSize->value();

        _xAxisRange->m_isAutoRange = axiRangIsAutoRange;

        double axiRangMaxValue = _doubleSpinBox_maxValue->value();
        double axiRangMinValue = _doubleSpinBox_minValue->value();

        if (axiRangMaxValue == axiRangMinValue)
        {
            IdaDialogMsg::showDialog(this, QString("最大值与最小值不得相等，请重新输入"), EDialogMsg::Error, tr("X轴范围值设置错误"));
            return false;
        }

        double maxVal = qMax(axiRangMinValue, axiRangMaxValue);
        double minVal = qMin(axiRangMinValue, axiRangMaxValue);
        _xAxisRange->m_maxValue = maxVal;
        _xAxisRange->m_minValue = minVal;
        _doubleSpinBox_maxValue->setValue(maxVal);
        _doubleSpinBox_minValue->setValue(minVal);

        _xAxisRange->m_isAutoStepSize = axiRangIsAutoStepSize;
        _xAxisRange->m_customStepSize = axiRangCustomStepSize;
        return true;
        //_xAxisRange->m_isAutoScale = _checkBox_isAutoScale->isChecked();
        //_xAxisRange->m_mainScaleValue = _doubleSpinBox_mainScaleValue->value();
        //_xAxisRange->m_secondaryScaleValue = _doubleSpinBox_secondaryScaleValue->value();

        //m_pyCode.append(QString("linechartmainsetting.saveUIData_xAxisRange(%1,%2,%3,%4,%5)")
        //                    .arg(axiRangIsAutoRange)
        //                    .arg(axiRangMaxValue)
        //                    .arg(axiRangMinValue)
        //                    .arg(axiRangIsAutoStepSize)
        //                    .arg(axiRangCustomStepSize));
    }

    void LineChartCenterSettingDialog::saveUIData_yAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_yAxisDisplay;
        auto _yAxisDisplay = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getYAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_axisUnitType = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                           // 轴类别
        auto _comboBox_axisComponentType = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                  // 分量类别
        auto _comboBox_axisUnit = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                           // 单位
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小


        QColor yAxiDisTitleFontColor = _comboBox_titleFontColor->currentColor();
        QColor yAxiDisAxisColor = _comboBox_axisColor->currentColor();
        QColor yAxiDisAxisDigitColor = _comboBox_axisDigitColor->currentColor();

        bool yAxiDisIsAutoName = _checkBox_isAutoName->isChecked();
        QString yAxiDisTitleText = _lineEdit_title->text();
        int yAxiDisAxisType = _comboBox_axisUnitType->currentIndex();
        QString yAxisComponentTypeText = _comboBox_axisComponentType->currentText();
        int yAxisComponentType= UnitHelper::getComponentTypeByName(yAxisComponentTypeText);//根据字符串转为分量int
        QString axisUnit = _comboBox_axisUnit->currentText();
        QString yAxiDisTitleFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{yAxiDisTitleFontColor.red(), yAxiDisTitleFontColor.green(), yAxiDisTitleFontColor.blue()});
        int yAxiDisTitleFontSize = _comboBox_titleFontSize->currentText().toInt();
        QString yAxiDisAxisColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{yAxiDisAxisColor.red(), yAxiDisAxisColor.green(), yAxiDisAxisColor.blue()});
        int yAxiDisAxisThickness = _comboBox_axisThickness->currentText().toInt();
        auto yAxiDisValuePrecision = _SpinBox_valuePrecision->value();
        QString yAxiDisAxisDigitColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{yAxiDisAxisDigitColor.red(), yAxiDisAxisDigitColor.green(), yAxiDisAxisDigitColor.blue()});
        int yAxiDisAxisDigitSize = _comboBox_axisDigitSize->currentText().toInt();

        _yAxisDisplay->m_isAutoName = yAxiDisIsAutoName;
        _yAxisDisplay->m_titleText = yAxiDisTitleText;
        //_yAxisDisplay->m_unitType = yAxiDisAxisType;
        //_yAxisDisplay->m_xAxisUnit = axisUnit;
        _yAxisDisplay->m_yAxisUnitList = this->m_yAxisUnitList;
        _yAxisDisplay->m_titleFontColor = yAxiDisTitleFontColor;
        _yAxisDisplay->m_titleFontSize = yAxiDisTitleFontSize;
        _yAxisDisplay->m_axisColor = yAxiDisAxisColor;
        _yAxisDisplay->m_axisThickness = yAxiDisAxisThickness;
        _yAxisDisplay->m_valuePrecision = yAxiDisValuePrecision;
        _yAxisDisplay->m_axisDigitColor = yAxiDisAxisDigitColor;
        _yAxisDisplay->m_axisDigitSize = yAxiDisAxisDigitSize;

        ////TODO 修改脚本，传递m_unit m_yAxisUnitList
        //m_pyCode.append(QString("linechartmainsetting.saveUIData_yAxisDisplay(%1,'%2','%3',%4,'%5',%6, %7,'%8',%9)")
        //                    .arg(yAxiDisIsAutoName)
        //                    .arg(yAxiDisTitleText)
        //                    .arg(yAxiDisTitleFontColorStr)
        //                    .arg(yAxiDisTitleFontSize)
        //                    .arg(yAxiDisAxisColorStr)
        //                    .arg(yAxiDisAxisThickness)
        //                    .arg(yAxiDisValuePrecision)
        //                    .arg(yAxiDisAxisDigitColorStr)
        //                    .arg(yAxiDisAxisDigitSize));
    }

    bool LineChartCenterSettingDialog::saveUIData_yAxisRange()
    {
        auto _tableWidget = m_tableWidget_yAxisRange;
        auto _yAxisRange = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getYAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长
        // auto _checkBox_isAutoScale = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);        //自动最小刻度
        // auto _doubleSpinBox_mainScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);    //自定义最小刻度数
        // auto _doubleSpinBox_secondaryScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);  //次刻度值

        bool yAxiRangIsAutoRange = _checkBox_isAutoRange->isChecked();
        double yAxiRangMaxValue = _doubleSpinBox_maxValue->value();
        double yAxiRangMinValue = _doubleSpinBox_minValue->value();

        if (yAxiRangMaxValue == yAxiRangMinValue)
        {
            IdaDialogMsg::showDialog(this, QString("最大值与最小值不得相等，请重新输入"), EDialogMsg::Error, tr("Y轴范围值设置错误"));
            return false;
        }

        bool yAxiRangIsAutoStepSize = _checkBox_isAutoStepSize->isChecked();
        double yAxiRangCustomStepSize = _doubleSpinBox_customStepSize->value();

        _yAxisRange->m_isAutoRange = yAxiRangIsAutoRange;

        double yMaxVal = qMax(yAxiRangMaxValue, yAxiRangMinValue);
        double yMinVal = qMin(yAxiRangMaxValue, yAxiRangMinValue);
        _yAxisRange->m_maxValue = yMaxVal;
        _yAxisRange->m_minValue = yMinVal;
        _doubleSpinBox_maxValue->setValue(yMaxVal);
        _doubleSpinBox_minValue->setValue(yMinVal);

        _yAxisRange->m_isAutoStepSize = yAxiRangIsAutoStepSize;
        _yAxisRange->m_customStepSize = yAxiRangCustomStepSize;
        return true;
        //_yAxisRange->m_isAutoScale = _checkBox_isAutoScale->isChecked();
        //_yAxisRange->m_mainScaleValue = _doubleSpinBox_mainScaleValue->value();
        //_yAxisRange->m_secondaryScaleValue = _doubleSpinBox_secondaryScaleValue->value();

        //m_pyCode.append(QString("linechartmainsetting.saveUIData_yAxisRange(%1,%2,%3,%4,%5)")
        //                    .arg(yAxiRangIsAutoRange)
        //                    .arg(yAxiRangMaxValue)
        //                    .arg(yAxiRangMinValue)
        //                    .arg(yAxiRangIsAutoStepSize)
        //                    .arg(yAxiRangCustomStepSize));
    }

    void LineChartCenterSettingDialog::saveUIData_grid()
    {
        auto _tableWidget = m_tableWidget_grid;
        auto _grid = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getGrid();

        int _rowCount = -1;
        auto _checkBox_isMainGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 是否主网格线显示
        auto _comboBox_mainGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);      // 主网格线颜色
        auto _comboBox_mainGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 主网格线样式
        auto _comboBox_mainGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 主网格线粗细
        auto _doubleSpinBox_isSecondaryGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);         // 是否次网格线显示
        auto _comboBox_secondaryGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 次网格线颜色
        auto _comboBox_secondaryGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                  // 次网格线样式
        auto _comboBox_secondaryGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 次网格线粗细

        QColor gridMainGridLineColor = _comboBox_mainGridLineColor->currentColor();
        QColor gridSecondaryGridLineColor = _comboBox_secondaryGridLineColor->currentColor();

        bool gridIsMainGridLineDisplay = _checkBox_isMainGridLineDisplay->isChecked();
        QString gridMainGridLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{gridMainGridLineColor.red(), gridMainGridLineColor.green(), gridMainGridLineColor.blue()});
        int gridMainGridLineStyle = _comboBox_mainGridLineStyle->currentIndex();
        double gridMainGridLineThickness = _comboBox_mainGridLineThickness->currentText().toDouble();
        bool gridIsSecondaryGridLineDisplay = _doubleSpinBox_isSecondaryGridLineDisplay->isChecked();
        QString gridSecondaryGridLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{gridSecondaryGridLineColor.red(), gridSecondaryGridLineColor.green(), gridSecondaryGridLineColor.blue()});
        int gridSecondaryGridLineStyle = _comboBox_secondaryGridLineStyle->currentIndex();
        double gridSecondaryGridLineThickness = _comboBox_secondaryGridLineThickness->currentText().toDouble();

        _grid->m_isMainGridLineDisplay = gridIsMainGridLineDisplay;
        _grid->m_mainGridLineColor = gridMainGridLineColor;
        _grid->m_mainGridLineStyle = gridMainGridLineStyle;
        _grid->m_mainGridLineThickness = gridMainGridLineThickness;
        _grid->m_isSecondaryGridLineDisplay = gridIsSecondaryGridLineDisplay;
        _grid->m_secondaryGridLineColor = gridSecondaryGridLineColor;
        _grid->m_secondaryGridLineStyle = gridSecondaryGridLineStyle;
        _grid->m_secondaryGridLineThickness = gridSecondaryGridLineThickness;

        //m_pyCode.append(QString("linechartmainsetting.saveUIData_grid(%1,'%2',%3,%4,%5,'%6',%7,%8)")
        //                    .arg(gridIsMainGridLineDisplay)
        //                    .arg(gridMainGridLineColorStr)
        //                    .arg(gridMainGridLineStyle)
        //                    .arg(gridMainGridLineThickness)
        //                    .arg(gridIsSecondaryGridLineDisplay)
        //                    .arg(gridSecondaryGridLineColorStr)
        //                    .arg(gridSecondaryGridLineStyle)
        //                    .arg(gridSecondaryGridLineThickness));
    }

    void LineChartCenterSettingDialog::saveUIData_title()
    {
        auto _tableWidget = m_tableWidget_title;
        auto _title = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getTitle();

        int _rowCount = -1;
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                           // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 标题字体大小

        QColor titleFontColor = _comboBox_titleFontColor->currentColor();

        QString titleName = _lineEdit_title->text();
        QString titleFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{titleFontColor.red(), titleFontColor.green(), titleFontColor.blue()});
        int titleFontSize = _comboBox_titleFontSize->currentText().toInt();

        _title->m_titleName = titleName;
        _title->m_titleFontColor = titleFontColor;
        _title->m_titleFontSize = titleFontSize;

        //m_pyCode.append(QString("linechartmainsetting.saveUIData_title('%1','%2',%3)")
        //                    .arg(titleName)
        //                    .arg(titleFontColorStr)
        //                    .arg(titleFontSize));
    }

    void LineChartCenterSettingDialog::saveUIData_legend()
    {
        auto _tableWidget = m_tableWidget_legend;
        auto _legend = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getLegend();

        int _rowCount = -1;
        auto _comboBox_legendFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 图例字体颜色
        auto _comboBox_legendFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 图例字体大小
        auto _comboBox_legendLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 图例框线颜色
        auto _comboBox_legendLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 图例框线粗细

        QColor legendFontColor = _comboBox_legendFontColor->currentColor();
        QColor legendLineColor = _comboBox_legendLineColor->currentColor();

        QString legendFontColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{legendFontColor.red(), legendFontColor.green(), legendFontColor.blue()});
        int legendFontSize = _comboBox_legendFontSize->currentText().toInt();
        QString legendLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{legendLineColor.red(), legendLineColor.green(), legendLineColor.blue()});
        int legendLineThickness = _comboBox_legendLineThickness->currentText().toInt();

        _legend->m_legendFontColor = legendFontColor;
        _legend->m_legendFontSize = legendFontSize;
        _legend->m_legendLineColor = legendLineColor;
        _legend->m_legendLineThickness = legendLineThickness;

        //m_pyCode.append(QString("linechartmainsetting.saveUIData_legend('%1',%2,'%3',%4)")
        //                    .arg(legendFontColorStr)
        //                    .arg(legendFontSize)
        //                    .arg(legendLineColorStr)
        //                    .arg(legendLineThickness));
    }

    void LineChartCenterSettingDialog::saveUIData_dataProperty()
    {
        auto _tableWidget = m_tableWidget_dataProperty;
        auto _dataProperty = m_dataGraph2DSettings->m_style2D_DataProperty;
        if (_dataProperty == nullptr)
        {
            return;
        }
        int _rowCount = -1;
        auto _lineEdit_resultDataName = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                 // 结果数据名称
        auto _comboBox_dataLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 数据线颜色
        auto _comboBox_dataLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                  // 数据线样式
        auto _comboBox_dataLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 数据线粗细
        auto _checkBox_isDisplaySymbol = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                // 是否显示符号
        auto _comboBox_symbolStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                    // 符号样式
        auto _comboBox_symbolSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                     // 符号大小
        auto _comboBox_symbolColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);   // 符号颜色

        QColor dataLineColor = _comboBox_dataLineColor->currentColor();
        QColor symbolColor = _comboBox_symbolColor->currentColor();

        QString resultDataName = _lineEdit_resultDataName->text();
        QString dataLineColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{dataLineColor.red(), dataLineColor.green(), dataLineColor.blue()});
        int dataLineStyle = _comboBox_dataLineStyle->currentIndex();
        double dataLineThickness = _comboBox_dataLineThickness->currentText().toDouble();
        bool isDisplaySymbol = _checkBox_isDisplaySymbol->isChecked();
        int symbolStyle = _comboBox_symbolStyle->currentIndex();
        double symbolSize = _comboBox_symbolSize->currentText().toDouble();
        QString symbolColorStr = GlobalHelperInstance->convertIntListToQString(QList<int>{symbolColor.red(), symbolColor.green(), symbolColor.blue()});

        _dataProperty->m_resultDataName = resultDataName;
        _dataProperty->m_dataLineColor = dataLineColor;
        _dataProperty->m_dataLineStyle = dataLineStyle;
        _dataProperty->m_dataLineThickness = dataLineThickness;
        _dataProperty->m_isDisplaySymbol = isDisplaySymbol;
        _dataProperty->m_symbolStyle = symbolStyle;
        _dataProperty->m_symbolSize = symbolSize;
        _dataProperty->m_symbolColor = symbolColor;

        //m_pyCode.append(QString("linechartmainsetting.saveUIData_dataProperty('%1','%2',%3,%4,%5,%6,%7,'%8')")
        //                    .arg(resultDataName)
        //                    .arg(dataLineColorStr)
        //                    .arg(dataLineStyle)
        //                    .arg(dataLineThickness)
        //                    .arg(isDisplaySymbol)
        //                    .arg(symbolStyle)
        //                    .arg(symbolSize)
        //                    .arg(symbolColorStr));
    }

    void LineChartCenterSettingDialog::updateUIData_xAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_xAxisDisplay;
        auto _xAxisDisplay = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getXAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_axisUnit = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                           // 轴单位
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小

        //x轴单位相关设置
        QSignalBlocker blocker1(_comboBox_axisUnit);
        _comboBox_axisUnit->clear();
        auto unitList = UnitHelper::getKeyUnitListOfType(_xAxisDisplay->m_xUnitType);
        for (const auto& i : unitList)
        {
            _comboBox_axisUnit->addItem(i);
        }
        _comboBox_axisUnit->setCurrentText(_xAxisDisplay->m_xAxisUnit);

        _checkBox_isAutoName->setChecked(_xAxisDisplay->m_isAutoName);
        _lineEdit_title->setText(_xAxisDisplay->m_titleText);
        _comboBox_titleFontColor->setCurrentColor(_xAxisDisplay->m_titleFontColor);
        _comboBox_titleFontSize->setCurrentText(QString::number(_xAxisDisplay->m_titleFontSize));
        _comboBox_axisColor->setCurrentColor(_xAxisDisplay->m_axisColor);
        _comboBox_axisThickness->setCurrentText(QString::number(_xAxisDisplay->m_axisThickness));
        _SpinBox_valuePrecision->setValue(_xAxisDisplay->m_valuePrecision);
        _comboBox_axisDigitColor->setCurrentColor(_xAxisDisplay->m_axisDigitColor);
        _comboBox_axisDigitSize->setCurrentText(QString::number(_xAxisDisplay->m_axisDigitSize));
    }

    void LineChartCenterSettingDialog::updateUIData_xAxisRange()
    {
        auto _tableWidget = m_tableWidget_xAxisRange;
        auto _xAxisRange = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getXAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长
        // auto _checkBox_isAutoScale = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);        //自动最小刻度
        // auto _doubleSpinBox_mainScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);    //自定义最小刻度数
        // auto _doubleSpinBox_secondaryScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);  //次刻度值

        _checkBox_isAutoRange->setChecked(_xAxisRange->m_isAutoRange);
        _doubleSpinBox_maxValue->setValue(_xAxisRange->m_maxValue);
        _doubleSpinBox_minValue->setValue(_xAxisRange->m_minValue);
        _checkBox_isAutoStepSize->setChecked(_xAxisRange->m_isAutoStepSize);
        _doubleSpinBox_customStepSize->setValue(_xAxisRange->m_customStepSize);
        //_checkBox_isAutoScale->setChecked(_xAxisRange->m_isAutoScale);
        //_doubleSpinBox_mainScaleValue->setValue(_xAxisRange->m_mainScaleValue);
        //_doubleSpinBox_secondaryScaleValue->setValue(_xAxisRange->m_secondaryScaleValue);
    }

    void LineChartCenterSettingDialog::updateUIData_yAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_yAxisDisplay;
        auto _yAxisDisplay = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getYAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_axisType = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                           // 轴类别
        auto _comboBox_componentType = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                        //分量类别
        auto _comboBox_axisUnit = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                           // 轴单位
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小

        //y轴单位相关设置
        m_yAxisUnitList = _yAxisDisplay->m_yAxisUnitList;
        QSignalBlocker blocker(_comboBox_axisType);
        QSignalBlocker blocker1(_comboBox_componentType);
        QSignalBlocker blocker3(_comboBox_axisUnit);
        _comboBox_axisType->clear();
        _comboBox_componentType->clear();
        _comboBox_axisUnit->clear();


        //getAddedComponentTypeListByFileType

        //TODO 更新分量
        if (!m_yAxisUnitList.empty())
        {
            QList<QString> addedFileType;
            for (const auto &i : m_yAxisUnitList)
            {
                QString typeName = UnitHelper::getValueTypeAsString(std::get<0>(i));
                if (addedFileType.contains(typeName))
                {
                    continue;
                }
                _comboBox_axisType->addItem(typeName);
                addedFileType.append(typeName);
            }


            //添加分量
            auto _componentTypeList = getAddedComponentTypeListByFileType(std::get<0>(m_yAxisUnitList[0]));
            for (const auto& i : _componentTypeList)
            {
                auto text = UnitHelper::getComponentNameByType(i);
                _comboBox_componentType->addItem(text);
            }

            //添加单位
            auto _yAxisUnitList = UnitHelper::getValueUnitListOfType(std::get<0>(m_yAxisUnitList[0]), std::get<1>(m_yAxisUnitList[0]));
            for (const auto& i : _yAxisUnitList)
            {
                _comboBox_axisUnit->addItem(i);
            }

            _comboBox_axisType->setCurrentIndex(0);
            _comboBox_componentType->setCurrentIndex(0);
            _comboBox_axisUnit->setCurrentText(std::get<2>(m_yAxisUnitList[0]));
        }

        _checkBox_isAutoName->setChecked(_yAxisDisplay->m_isAutoName);
        _lineEdit_title->setText(_yAxisDisplay->m_titleText);
        _comboBox_titleFontColor->setCurrentColor(_yAxisDisplay->m_titleFontColor);
        _comboBox_titleFontSize->setCurrentText(QString::number(_yAxisDisplay->m_titleFontSize));
        _comboBox_axisColor->setCurrentColor(_yAxisDisplay->m_axisColor);
        _comboBox_axisThickness->setCurrentText(QString::number(_yAxisDisplay->m_axisThickness));
        _SpinBox_valuePrecision->setValue(_yAxisDisplay->m_valuePrecision);
        _comboBox_axisDigitColor->setCurrentColor(_yAxisDisplay->m_axisDigitColor);
        _comboBox_axisDigitSize->setCurrentText(QString::number(_yAxisDisplay->m_axisDigitSize));
    }

    void LineChartCenterSettingDialog::updateUIData_yAxisRange()
    {
        auto _tableWidget = m_tableWidget_yAxisRange;
        auto _yAxisRange = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getYAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长
        // auto _checkBox_isAutoScale = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);        //自动最小刻度
        // auto _doubleSpinBox_mainScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);    //自定义最小刻度数
        // auto _doubleSpinBox_secondaryScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);  //次刻度值

        _checkBox_isAutoRange->setChecked(_yAxisRange->m_isAutoRange);
        _doubleSpinBox_maxValue->setValue(_yAxisRange->m_maxValue);
        _doubleSpinBox_minValue->setValue(_yAxisRange->m_minValue);
        _checkBox_isAutoStepSize->setChecked(_yAxisRange->m_isAutoStepSize);
        _doubleSpinBox_customStepSize->setValue(_yAxisRange->m_customStepSize);
        //_checkBox_isAutoScale->setChecked(_yAxisRange->m_isAutoScale);
        //_doubleSpinBox_mainScaleValue->setValue(_yAxisRange->m_mainScaleValue);
        //_doubleSpinBox_secondaryScaleValue->setValue(_yAxisRange->m_secondaryScaleValue);
    }

    void LineChartCenterSettingDialog::updateUIData_grid()
    {
        auto _tableWidget = m_tableWidget_grid;
        auto _grid = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getGrid();

        int _rowCount = -1;
        auto _checkBox_isMainGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 是否主网格线显示
        auto _comboBox_mainGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);      // 主网格线颜色
        auto _comboBox_mainGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 主网格线样式
        auto _comboBox_mainGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 主网格线粗细
        auto _doubleSpinBox_isSecondaryGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);         // 是否次网格线显示
        auto _comboBox_secondaryGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 次网格线颜色
        auto _comboBox_secondaryGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                  // 次网格线样式
        auto _comboBox_secondaryGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 次网格线粗细

        _checkBox_isMainGridLineDisplay->setChecked(_grid->m_isMainGridLineDisplay);
        _comboBox_mainGridLineColor->setCurrentColor(_grid->m_mainGridLineColor);
        _comboBox_mainGridLineStyle->setCurrentIndex(_grid->m_mainGridLineStyle);
        _comboBox_mainGridLineThickness->setCurrentText(QString::number(_grid->m_mainGridLineThickness));
        _doubleSpinBox_isSecondaryGridLineDisplay->setChecked(_grid->m_isSecondaryGridLineDisplay);
        _comboBox_secondaryGridLineColor->setCurrentColor(_grid->m_secondaryGridLineColor);
        _comboBox_secondaryGridLineStyle->setCurrentIndex(_grid->m_secondaryGridLineStyle);
        _comboBox_secondaryGridLineThickness->setCurrentText(QString::number(_grid->m_secondaryGridLineThickness));

        if (!_grid->m_isMainGridLineDisplay)
        {
            _doubleSpinBox_isSecondaryGridLineDisplay->setEnabled(false);
        }
        else 
        {
            _doubleSpinBox_isSecondaryGridLineDisplay->setEnabled(true);
        }
    }

    void LineChartCenterSettingDialog::updateUIData_title()
    {
        auto _tableWidget = m_tableWidget_title;
        auto _title = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getTitle();

        int _rowCount = -1;
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                           // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 标题字体大小

        _lineEdit_title->setText(_title->m_titleName);
        _comboBox_titleFontColor->setCurrentColor(_title->m_titleFontColor);
        _comboBox_titleFontSize->setCurrentText(QString::number(_title->m_titleFontSize));
    }

    void LineChartCenterSettingDialog::updateUIData_legend()
    {
        auto _tableWidget = m_tableWidget_legend;
        auto _legend = m_dataGraph2DSettings->m_lineChartCoordinateSettingData->getLegend();

        int _rowCount = -1;
        auto _comboBox_legendFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 图例字体颜色
        auto _comboBox_legendFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 图例字体大小
        auto _comboBox_legendLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 图例框线颜色
        auto _comboBox_legendLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 图例框线粗细

        _comboBox_legendFontColor->setCurrentColor(_legend->m_legendFontColor);                         // 图例字体颜色
        _comboBox_legendFontSize->setCurrentText(QString::number(_legend->m_legendFontSize));           // 图例字体大小
        _comboBox_legendLineColor->setCurrentColor(_legend->m_legendLineColor);                         // 图例框线颜色
        _comboBox_legendLineThickness->setCurrentText(QString::number(_legend->m_legendLineThickness)); // 图例框线粗细
    }

    void LineChartCenterSettingDialog::updateUIData_dataProperty()
    {
        auto _tableWidget = m_tableWidget_dataProperty;
        auto _dataProperty = m_dataGraph2DSettings->m_style2D_DataProperty;
        if (_dataProperty == nullptr)
        {
            return;
        }

        int _rowCount = -1;
        auto _lineEdit_resultDataName = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                 // 结果数据名称
        auto _comboBox_dataLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 数据线颜色
        auto _comboBox_dataLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                  // 数据线样式
        auto _comboBox_dataLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 数据线粗细
        auto _checkBox_isDisplaySymbol = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                // 是否显示符号
        auto _comboBox_symbolStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                    // 符号样式
        auto _comboBox_symbolSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                     // 符号大小
        auto _comboBox_symbolColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);   // 符号颜色

        _lineEdit_resultDataName->setText(_dataProperty->m_resultDataName);                               // 结果数据名称
        _comboBox_dataLineColor->setCurrentColor(_dataProperty->m_dataLineColor);                         // 数据线颜色
        _comboBox_dataLineStyle->setCurrentIndex(_dataProperty->m_dataLineStyle);                         // 数据线样式
        _comboBox_dataLineThickness->setCurrentText(QString::number(_dataProperty->m_dataLineThickness)); // 数据线粗细
        _checkBox_isDisplaySymbol->setChecked(_dataProperty->m_isDisplaySymbol);                          // 是否显示符号
        _comboBox_symbolStyle->setCurrentIndex(_dataProperty->m_symbolStyle);                             // 符号样式
        _comboBox_symbolSize->setCurrentText(QString::number(_dataProperty->m_symbolSize));               // 符号大小
        _comboBox_symbolColor->setCurrentColor(_dataProperty->m_symbolColor);                             // 符号颜色
    }

    QList<int> LineChartCenterSettingDialog::getAddedComponentTypeListByFileType(int fileType)
    {
        QList<int> returnList;
        for (const auto& i : m_yAxisUnitList)
        {
            if (std::get<0>(i) == fileType)
            {
                returnList.append(std::get<1>(i));
            }
        }

        return returnList;
    }

    QString LineChartCenterSettingDialog::getCurrentUnitByType(int fileType, int componentType)
    {
        for (const auto& i : m_yAxisUnitList)
        {
            if (std::get<0>(i) == fileType && std::get<1>(i) == componentType)
            {
                return std::get<2>(i);
            }
        }

        return QString();
    }

    void LineChartCenterSettingDialog::slot_xAxisUnitChanged(int index)
    {
    }

    void LineChartCenterSettingDialog::slot_yAxisUnittypeChanged(int index)
    {
        QSignalBlocker bocker(m_comboBox_yAxisComponentType);
        m_comboBox_yAxisComponentType->clear();

        //添加分量
        int fileType = UnitHelper::getValueTypeFromString(m_comboBox_yAxisUnitType->currentText());
        auto _componentTypeList = getAddedComponentTypeListByFileType(fileType);
        for (const auto& i : _componentTypeList)
        {
            auto text = UnitHelper::getComponentNameByType(i);
            m_comboBox_yAxisComponentType->addItem(text);
        }
        m_comboBox_yAxisComponentType->setCurrentIndex(0);
        slot_yAxisUnitComponentChanged(0);
    }

    void LineChartCenterSettingDialog::slot_yAxisUnitComponentChanged(int index)
    {
        QSignalBlocker bocker(m_comboBox_yAxisUnit);
        m_comboBox_yAxisUnit->clear();

        int fileType = UnitHelper::getValueTypeFromString(m_comboBox_yAxisUnitType->currentText());
        QString currentComponentStr = m_comboBox_yAxisComponentType->currentText();
        int currentComponentType = UnitHelper::getComponentTypeByName(currentComponentStr);

        auto _yAxisUnitList = UnitHelper::getValueUnitListOfType(fileType, currentComponentType);
        for (const auto& i : _yAxisUnitList)
        {
            m_comboBox_yAxisUnit->addItem(i);
        }
        auto currentChosenUnit = getCurrentUnitByType(fileType, currentComponentType);
        m_comboBox_yAxisUnit->setCurrentText(currentChosenUnit);
    }

    void LineChartCenterSettingDialog::slot_yAxisUnitChanged(int index)
    {
        int fileType = UnitHelper::getValueTypeFromString(m_comboBox_yAxisUnitType->currentText());
        QString currentComponentStr = m_comboBox_yAxisComponentType->currentText();
        int currentComponentIndex = UnitHelper::getComponentTypeByName(currentComponentStr);

        for (auto& i : m_yAxisUnitList)
        {
            if (std::get<0>(i) == fileType && std::get<1>(i) == currentComponentIndex)
            {
                std::get<2>(i) = m_comboBox_yAxisUnit->currentText();
            }
        }
    }

} // namespace pst
